<script lang="ts" setup>

import { onMounted, ref, onBeforeMount } from 'vue';

import { Search } from '@element-plus/icons-vue'
const tableData = [
  {
    date: '2016-05-03',
    name: 'Tom',
    state: 'California',
    city: 'Los Angeles',
    address: 'No. 189, Grove St, Los Angeles',
    zip: 'CA 90036',
  },
  {
    date: '2016-05-02',
    name: 'Tom',
    state: 'California',
    city: 'Los Angeles',
    address: 'No. 189, Grove St, Los Angeles',
    zip: 'CA 90036',
  },
  {
    date: '2016-05-04',
    name: 'Tom',
    state: 'California',
    city: 'Los Angeles',
    address: 'No. 189, Grove St, Los Angeles',
    zip: 'CA 90036',
  },
  {
    date: '2016-05-01',
    name: 'Tom',
    state: 'California',
    city: 'Los Angeles',
    address: 'No. 189, Grove St, Los Angeles',
    zip: 'CA 90036',
  },
  {
    date: '2016-05-08',
    name: 'Tom',
    state: 'California',
    city: 'Los Angeles',
    address: 'No. 189, Grove St, Los Angeles',
    zip: 'CA 90036',
  },
  {
    date: '2016-05-06',
    name: 'Tom',
    state: 'California',
    city: 'Los Angeles',
    address: 'No. 189, Grove St, Los Angeles',
    zip: 'CA 90036',
  },
  {
    date: '2016-05-07',
    name: 'Tom',
    state: 'California',
    city: 'Los Angeles',
    address: 'No. 189, Grove St, Los Angeles',
    zip: 'CA 90036',
  },
]
const input2 = ref('')
const currentPage2 = ref(5)
const pageSize2 = ref(100)
const size = ref(10)
const background = ref(false)

const handleSizeChange = (val: number) => {
  console.log(`${val} items per page`)
}
const handleCurrentChange = (val: number) => {
  console.log(`current page: ${val}`)
}
const active = ref('0')
const changeAct = (val: any) => {
  active.value = val
}
const testAct = ref('0')
const changeTest = (val: any) => {
  testAct.value = val
}

</script>
<template>
  <div class="container1 container ">

    <div class="searchHeader">
      <button @click="changeAct('0')" :class="active == '0' ? 'on' : ''">公示试验</button>
      <button @click="changeAct('1')" :class="active == '1' ? 'on' : ''">试验线索</button>
      <el-input v-model="input2" class="input" placeholder="请输入试验名称、申办者、要求搜索">
        <template #suffix>
          <el-icon style="color: #0C9397;">
            <Search />
          </el-icon>
        </template>
      </el-input>
      <div style="flex: 1;justify-content: flex-end;display: flex;">
        <button class="add">发布新线索</button>
      </div>
    </div>
    <div class="openTest">
      <span>试验数目：{{ 222 }}</span>
      <button @click="changeTest('0')" :class="testAct == '0' ? 'teston' : ''">进行中</button>
      <button @click="changeTest('1')" :class="testAct == '1' ? 'teston' : ''">已完成</button>
      <button @click="changeTest('2')" :class="testAct == '2' ? 'teston' : ''">主动暂停</button>

    </div>
    <div>
      <el-table v-if="active == '0'" :data="tableData" align="left" header-row-class-name="headerName" :border="false"
        style="width: 100%;height: calc(100% - 20px);">
        <el-table-column prop="date" label="项目名称" />
        <el-table-column prop="date" label="申办者" />
        <el-table-column prop="date" label="要求" />
        <el-table-column prop="date" label="操作" width="180">
          <template #default="scope">
            <el-button size="mini" style="color: #0C9397;" link> 合作咨询 </el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-table class="testTable" v-if="active == '1'" :data="tableData" align="left" header-row-class-name="headerName" :border="false"
        style="width: 100%">
        <el-table-column type="expand">
          <template #default="props">
            <div class="expandData">
              <p>登记号:CTR20244572 </p>
              <p>试验分类:药代动力学/药效动力学试验</p>

            </div>
          </template>
        </el-table-column>

        <el-table-column prop="date" label="试验名称" width="300">
          <template #default="scope">
            <p style="color: #0C9397;">试验分类:药代动力学/药效动力学试验</p>

          </template>
        </el-table-column>
        <el-table-column prop="date" label="适应症" />
        <el-table-column prop="date" label="研究中心" />
        <el-table-column prop="date" label="主要研究者" />

        <el-table-column prop="date" label="申办方" />

        <el-table-column prop="date" label="分期" width="180">
          <template #default="scope">
            <!-- <el-button size="mini" style="color: #0C9397;" link> 合作咨询 </el-button> -->
          </template>
        </el-table-column>
      </el-table>
      <div class="pagination">
        <el-pagination v-model:current-page="currentPage2" v-model:page-size="pageSize2"
          :page-sizes="[10, 200, 300, 400]" :size="size" :background="true" layout="prev, pager, next,sizes,"
          :total="1000" @size-change="handleSizeChange" @current-change="handleCurrentChange" />
      </div>


    </div>
  </div>

</template>
<style scoped lang="scss">
.container {
  background-color: #fff;
  height: calc(100% - 40px);
  margin: 20px auto;
  padding: 20px;
}

button {
  width: 120px;
  height: 36px;
  background-color: #F5F5F5;
  font-size: 16px;
  margin-right: 11px;
  cursor: pointer;
  color: #333333;
}

.on {
  background-color: #0C9397;
  color: #fff;
}

.searchHeader {
  display: flex;
  margin-bottom: 13px;

  .input {
    width: 400px;
  }



  .add {
    border: 1px solid #0C9397;
    color: #0C9397;
    background-color: rgba(12, 147, 151, .1);
    margin: 0;
  }
}

.pagination {
  margin-top: 30px;
  display: flex;
  justify-content: flex-end;
}

.openTest {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-bottom: 20px;

  button {
    margin: 0;
    border: 1px solid #0C9397;
    color: #0C9397;
    background-color: rgba(12, 147, 151, .1);
  }

  span {
    margin-right: 12px;
    color: #666;
  }

  .teston {
    background-color: #0C9397;
    color: #fff;
  }
}

.expandData {
  background: #F5F5F5;
  margin: 10px 20px;

  p {
    font-size: 16px;
    color: #666666;
    margin-top: 10px;
  }
}
</style>